export const getTree = (data: any) => {
  let newArr = []
  let z = 0
  for (let i = 0; i < data.length; i++) {
    if (!newArr[newArr.length - 1] || newArr[newArr.length - 1].level == data[i].level) {
      newArr.push(data[i])
      continue
    }
    if (!newArr[newArr.length - 1].children) {
      newArr[newArr.length - 1].children = []
    }
    if (newArr[newArr.length - 1].level + 1 == data[i].level) {

      newArr[newArr.length - 1].children.push(data[i])
    } else {

      newArr[newArr.length - 1].children.push(data[i])
      newArr[newArr.length - 1].children = getTree(newArr[newArr.length - 1].children)
    }
  }
  return newArr
}